<%--
  Created by IntelliJ IDEA.
  User: fenglixiong
  Date: 2017/10/2
  Time: 20:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
    <title>房间列表</title>
    <script type="text/javascript" src="/static/js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/static/js/globalPage.js"></script>
    <script type="text/javascript">
        function loadDate(){
            document.fs.submit();
        }
    </script>
</head>
<body>
<%@include file="../head_include.jsp"%>
<h1>房间列表</h1>
<form name="fs" action="roomList.htm" method="post">
    <input type="hidden" id="page" name="page" value="${ps.page}"/>
</form>
<a href="/room/roomAdd.htm" target="_blank">添加房间</a>
<table border="1">
    <thead>
    <tr>
        <th>ID</th>
        <th>UserId</th>
        <th>LastMsg</th>
        <th>LastTime</th>
        <th>CreateTime</th>
        <th>operate</th>
    </tr>
    </thead>
    <tbody>
    <c:if test="${empty roomList}">
        <tr>
            <td colspan="6">暂无数据！</td>
        </tr>
    </c:if>
    <c:if test="${not empty roomList}">
        <c:forEach items="${roomList}" var="room" varStatus="status">
            <tr>
                <td>${room.chatId}</td>
                <td>${room.userId}</td>
                <td>${room.lastMsg}</td>
                <td><fmt:formatDate value="${room.lastMsgTime}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
                <td><fmt:formatDate value="${room.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/> </td>
                <td>
                    <a href="/room/roomEdit.htm?roomId=${room.chatId}">修改</a>
                    <a href="/room/roomDelete.htm?roomId=${room.chatId}">删除</a>
                    <a href="/chat/chat.htm?roomId=${room.chatId}" target="_blank"><font color="red">发起聊天</font></a>
                </td>
            </tr>
        </c:forEach>
    </c:if>
    </tbody>
</table>
<div>
    <a href="javascript:void(0);" onclick="turnPage(1)">首页</a>
    <a href="javascript:void(0);" onclick="prePage()">上一页</a>
    <a href="javascript:void(0);" onclick="nextPage()">下一页</a>
    <a href="javascript:void(0);" onclick="turnPage('${ps.totalPage}')">尾页</a>
</div>

</body>
</html>